package cz.proks.easyhelpdesk.gae.core.manager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import cz.proks.easyhelpdesk.api.OAuth2TokenApi;
import cz.proks.easyhelpdesk.api.config.Configuration;
import cz.proks.easyhelpdesk.api.exception.ApiException;
import cz.proks.easyhelpdesk.api.model.OAuth2Token;

@Component
public class OAuth2TokenManager extends AManager<OAuth2Token> implements OAuth2TokenApi {   
    private final Logger log = LoggerFactory.getLogger(getClass());
    
    @Autowired
    @Qualifier(Configuration.Core.DB.OAUTH2_TOKEN_API)
    private OAuth2TokenApi dbApi;
    
    @Override
    protected OAuth2TokenApi getDbApi() {
        return dbApi;
    }
    
    @Override
    public void deleteAllForProviderId(String providerId) throws ApiException {
        log.debug("deleteAllForProviderId():: Start with providerId '{}'", providerId);
        
        dbApi.deleteAllForProviderId(providerId);
        
        log.debug("deleteAllForProviderId():: Exit"); 
    }     

}
